package str85_mapowanie_plikow_nio;

import java.awt.BorderLayout;
import java.io.IOException;

import javax.swing.JFrame;
import javax.swing.JTextArea;

public class Ramka extends JFrame {
	public Ramka(String filePath) throws IOException {
		setSize(600, 400);
		setTitle("Plik ze sciezki: " + filePath);
		setLocationRelativeTo(null);
		
		JTextArea textArea = new JTextArea();
		add(textArea, BorderLayout.CENTER);
		
		textArea.append("Input Stream:\n");
		long start = System.currentTimeMillis();
		long crcValue = Main.checksumInputStream(filePath);
		long end = System.currentTimeMillis();
		textArea.append("crc: " + Long.toHexString(crcValue) + "\n");
		textArea.append("time: " + (end - start) + " milisekund\n\n");
		
		textArea.append("Buffered Input Stream:\n");
		start = System.currentTimeMillis();
		crcValue = Main.checksumBufferedInputStream(filePath);
		end = System.currentTimeMillis();
		textArea.append("crc: " + Long.toHexString(crcValue) + "\n");
		textArea.append("time: " + (end - start) + " milisekund\n\n");
		
		textArea.append("Random Access File:\n");
		start = System.currentTimeMillis();
		crcValue = Main.checksumRandomAccessFile(filePath);
		end = System.currentTimeMillis();
		textArea.append("crc: " + Long.toHexString(crcValue) + "\n");
		textArea.append("time: " + (end - start) + " milisekund\n\n");
		
		textArea.append("Mapped File:\n");
		start = System.currentTimeMillis();
		crcValue = Main.checksumMappedFile(filePath);
		end = System.currentTimeMillis();
		textArea.append("crc: " + Long.toHexString(crcValue) + "\n");
		textArea.append("time: " + (end - start) + " milisekund\n\n");
	}
}
